home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / amitcp2_x_gcc.lha / sana2perror.c < prev    next >
C/C++ Source or Header  |  1994-01-12  |  2KB  |  64 lines

  1. char RCS_ID_SANA2PERROR_C[] = "$Id: sana2perror.c,v 1.3 1994/01/12 18:38:06 jasegler Exp jasegler $";
  2. /*
  3.  * sana2perror.c --- print SANA-II error message
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *                  All rights reserved.
  10.  *
  11.  * Created      : Sat Mar 20 02:10:14 1993 ppessi
  12.  * Last modified: Sun Jun 13 03:17:42 1993 ppessi
  13.  */
  14.  
  15. #ifdef KERNEL
  16. /*
  17.  * Note: This file is to be recompiled with AmiTCP/IP proper
  18.  *       with preprocessor symbol KERNEL defined.
  19.  *       You should NOT link it directly from "net.lib"!
  20.  */
  21. #include <conf.h>
  22. #include <sys/param.h>
  23. #include <sys/systm.h>
  24. #include <sys/syslog.h>
  25. #define fprintf log
  26. #define stderr LOG_ERR
  27. #else
  28. #include <stdio.h>
  29. #endif
  30.  
  31. #include <devices/sana2.h>
  32. #include <net/sana2errno.h>
  33.  
  34. void
  35. sana2perror (const char *banner, struct IOSana2Req *ios2)
  36. {
  37.   register WORD err = ios2->ios2_Req.io_Error;
  38.   register ULONG werr = ios2->ios2_WireError;
  39.   const char *errstr;
  40.  
  41.   if (err >= sana2io_nerr || -err > io_nerr)
  42.     {
  43.       errstr = io_errlist[0];
  44.     }
  45.   else
  46.     {
  47.       if (err < 0)
  48.     /* Negative error codes are common with all IO devices */
  49.     errstr = io_errlist[-err];
  50.       else
  51.     /* Positive error codes are SANA-II specific */
  52.     errstr = sana2io_errlist[err];
  53.     }
  54.  
  55.   if (werr == 0 || werr >= sana2wire_nerr)
  56.     {
  57.       fprintf (stderr, "%s: %s\n", banner, errstr);
  58.     }
  59.   else
  60.     {
  61.       fprintf (stderr, "%s: %s (%s)\n", banner, errstr, sana2wire_errlist[werr]);
  62.     }
  63. }
  64.